/**
 * 
 */
package com.application.Adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.application.Activity.R;
import com.application.Adapter.ListSubjectAdapter.ViewSubject;

/**
 * @author h
 *
 */
public class ListSubjectAdapter extends ArrayAdapter<ViewSubject>{
	private final Context _context;
	private final ArrayList<ViewSubject> _subContent;
	int _resource;
	
	/**
	 * @param cContext :truyen activity hien hanh
	 * @param iTextViewResourceId : truyen id widget
	 * @param arrSubject : truyen mang du lieu can load len custom view group
	 */
	public ListSubjectAdapter(Context cContext, int iTextViewResourceId,ArrayList<ViewSubject> arrSubject)
	{
		super(cContext,iTextViewResourceId,arrSubject);
		this._context = cContext;
		_resource=iTextViewResourceId;
		_subContent=arrSubject;
	}
	
	@Override
	public View getView(int iPosition, View vConvertView, ViewGroup vgParent) {
		final ViewSubject vsListSubject = _subContent.get(iPosition);
		
		View vRowView = vConvertView;
		if (vRowView == null) {
			LayoutInflater lInflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);;
			vRowView = lInflater.inflate(R.layout.listrow_listsubject,null, true);
		}
		if(vsListSubject !=null)
		{
			//holder = new ViewChatList();
			TextView tvClassName = (TextView) vRowView.findViewById(R.id.subject_tv_classname);
			TextView tvTeacherName = (TextView) vRowView.findViewById(R.id.subject_tv_teachername);
			ImageView img = (ImageView)vRowView.findViewById(R.id.subject_tv_imgnew);
			
			img.setVisibility(View.INVISIBLE);
			tvClassName.setText(vsListSubject.sViewClassname);
			tvTeacherName.setText(vsListSubject.sViewTeacherName);	
			
			if(vsListSubject.sStatus == true)
			{	
				img.setImageResource(R.drawable.img_new);
				img.setVisibility(View.VISIBLE);
			}
			
		}
        return vRowView;
		
	}
	
	public static class ViewSubject{
		public String sViewClassname;
		public String sViewTeacherName;
		public int sViewIDSubject;
		public boolean sStatus;
		public ViewSubject(String s1,String s2, int sub, boolean status)
		{
			this.sViewClassname=s1;
			this.sViewTeacherName=s2;
			this.sViewIDSubject = sub;
			this.sStatus = status;
		}		
	}
}
